<template>
  <div id="app">
    <router-view v-if="isRouterAlive" />
  </div>
</template>

<script>
import { getGlobal } from '@/utils/global';
import store from './store';
// import OfflineHandle from '@/components/OfflineHandle/index.vue';
export default {
  name: 'App',
  components: {
    // OfflineHandle
  },
  provide() { // 父组件中通过provide来提供变量，在子组件中通过inject来注入变量。
    return {
      reload: this.reload
    };
  },

  data() {
    return {
      isRouterAlive: true // 控制视图是否显示的变量
    };
  },
  created() {
    // 获取资源的时候加载
    const loading1 = this.$loading({
      lock: true,
      text: '正在初始化...',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    });
    loading1.close();
    setTimeout(async() => {
      await store.dispatch('getServerBg/getFiles');
      loading1.close();
    }, 1000);

    if (localStorage.getItem('isShowAllRoute') === '1') {
      localStorage.setItem('isHideLeft', 1);
      localStorage.setItem('isHideTop', 1);
    }
  },
  methods: {
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(function() {
        this.isRouterAlive = true;
      });
    }
  }
};
getGlobal().then((all) => {
  document.title = all.res.data.sysItemName;
});

</script>
<style>
@import "./styles/ele-date.scss";

/*定义滚动条高宽及背景
高宽分别对应横竖滚动条的尺寸*/
/* ::-webkit-scrollbar {
  width: 6px;
} */
/*定义滚动条轨道
  内阴影+圆角*/
::-webkit-scrollbar-track {
  background-color: rgba(0, 0, 0, 0);
}
/*定义滑块
  内阴影+圆角*/
::-webkit-scrollbar-thumb {
  border-radius: 61px;
  background-color: #99CBF9;
  /* -webkit-box-shadow: inset 0 10px 5px #000; */
}
</style>

